package com.huping.mapper;

import com.huping.pojo.Grade;
import com.huping.pojo.Homework;
import com.huping.pojo.SampleCase;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface SampleCaseMapper {

    @Delete("delete from sample_case where homework_id=#{homeworkId}")
    public int sampleCaseDelete(Integer homeworkId);

    @Insert("insert into sample_case (homework_id,input,output,type) values (#{homeworkId},#{input},#{output},#{type})")
    public int sampleCaseInsert(SampleCase sampleCase);

    @Select("select input,output,type from sample_case where homework_id=#{homeworkId}")
    public List<SampleCase> sampleCaseSelectByHomeworkId(Integer homeworkId);

    @Update("update grade set code=#{code},status=#{status},code_type=#{codeType} where grade_id=#{gradeId}")
    int updateSampleCase(Grade grade);

    @Select("select input,output,sample_case.type from sample_case where sample_case.homework_id=(select grade.homework_id from grade where grade_id=#{gradeId})")
    public List<SampleCase> getSampleCaseByGradeId(Integer gradeId);
}
